<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    body {
        background-color: #000;
    }

    .main {
        position: absolute;
        width: 400px;
        height: 150px;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        overflow: hidden;
        text-align: center;
        background-color: transparent;
        line-height: 150px;
        color: aquamarine;
        font-size: 30px;
        font-family: '宋体';
    }

    .main div {
        position: absolute;
    }

    .main :nth-child(1) {
        top: 0;
        left: 0;
        width: 100%;
        height: 2px;
        animation: run1 1s linear infinite;
        /* animation-delay: 0s;  */
        background: linear-gradient(to right, #fff, #acd, cyan);
    }

    .main :nth-child(2) {
        top: 0;
        right: 0;
        height: 100%;
        width: 2px;
        animation: run2 1s linear infinite;
        /* animation-delay: 1s; 设置动画延迟加载时间*/
        background: linear-gradient(to bottom, #fff, #acd, cyan);
    }

    .main :nth-child(3) {
        bottom: 0;
        left: 0;
        height: 2px;
        width: 100%;
        animation: run3 1s linear infinite;
        /* animation-delay: 2s; 设置动画延迟加载时间*/
        background: linear-gradient(to right, #fff, #acd, cyan);
    }

    .main :nth-child(4) {
        top: 0;
        left: 0;
        height: 100%;
        width: 2px;
        animation: run4 1s linear infinite;
        /* animation-delay: 3s; 设置动画延迟加载时间 */
        background: linear-gradient(to top, #fff, #acd, cyan);
    }

    @keyframes run1 {
        from {
            transform: translateX(-100%)
        }

        to {
            transform: translateX(100%)
        }
    }

    @keyframes run2 {
        from {
            transform: translateY(-100%)
        }

        to {
            transform: translateY(100%)
        }
    }

    @keyframes run3 {
        from {
            transform: translateX(100%)
        }

        to {
            transform: translateX(-100%)
        }
    }

    @keyframes run4 {
        from {
            transform: translateY(100%)
        }

        to {
            transform: translateY(-100%)
        }
    }
</style>

<body>
    <div class="main">
        海绵宝宝
        <div></div>
        <div></div>
        <div></div>
        <div></div>
    </div>
</body>

</html>